<template>
  <div v-if="showBlackMask" class="div-mask">
    <div class="div-mask-main">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "index",
  props: {
    isShow: {
      type: Boolean,
      required: true
    }
  },
  data() {
    return {
      showBlackMask: false
    }
  },
  mounted() {
    this.showBlackMask = this.isShow;
    if (this.isShow) {
      document.documentElement.style.overflow = "hidden";
    } else {
      document.documentElement.style.overflow = "scroll";
    }
  },
  watch: {
    isShow(n) {
      this.showBlackMask = n;
      if (n) {
        document.documentElement.style.overflow = "hidden";
      } else {
        document.documentElement.style.overflow = "scroll";
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.div-mask {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1999;

  display: flex;
  justify-content: center;
  align-items: center;

  .div-mask-main {

  }
}
</style>